package com.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shop.mapper.ItemsImgMapper;
import com.shop.pojo.ItemsImg;
import com.shop.service.ItemsImgService;
import com.shop.vo.ItemsImgQueryRequest;
import com.shop.vo.ItemsImgSaveRequest;
import com.shop.vo.ItemsImgUpdateRequest;
import org.springframework.beans.BeanUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.metadata.IPage;


@Service("itemsImgService")
public class ItemsImgServiceImpl extends ServiceImpl<ItemsImgMapper, ItemsImg> implements ItemsImgService {

    @Override
    public IPage<ItemsImg> page(Page page, ItemsImgQueryRequest request){
        QueryWrapper<ItemsImg> wrapper = ItemsImg.queryWrapper(request);
        return this.page(page,wrapper);
    }

    @Transactional
    @Override
    public void save(ItemsImgSaveRequest request){
        ItemsImg itemsImg = new ItemsImg();
        BeanUtils.copyProperties(request,itemsImg);
        this.save(itemsImg);
    }

    @Transactional
    @Override
    public void update(ItemsImgUpdateRequest request){
        ItemsImg itemsImg = new ItemsImg();
        BeanUtils.copyProperties(request,itemsImg);
        this.updateById(itemsImg);
    }

    @Transactional
    @Override
    public void delete(String id){
        UpdateWrapper<ItemsImg> updateWrapper = new UpdateWrapper();
        this.update(updateWrapper);
    }

}